package clt.com.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import clt.com.mapper.CompanyMapper;
import clt.com.mapper.PersonMapper;
import clt.com.object.Company;
import clt.com.service.ICompanyService;
import clt.com.service.common.impl.BaseServiceImpl;
import clt.com.util.StringUtil;

@Service("companyService")
public class CompanyServiceImpl extends BaseServiceImpl implements ICompanyService{
	@Autowired
    private CompanyMapper companyMapper;
	@Autowired
	private PersonMapper personMapper;
	/**
	 * 
	 * @Title  公司介绍查询
	 * @Description:  queryCompanyList
	 * @param: @param compay
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年8月15日
	 */
	public Map<String,Object> queryCompanyList(Map<String,String> map){
		List<Map<String,String>> list = companyMapper.queryCompanyList(map);
		int count = companyMapper.queryCompanyListCount(map);
		Map<String,String> bean = new HashMap<>();
		bean.put("total", Integer.toString(count));
		Map<String,Object> map1 = new HashMap<>();
		map1.put("beans", list);
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", ""); 
		return map1;
	}
	/**
	 * 
	 * @Title  公司介详情查询
	 * @Description:  queryCompanyDtlById
	 * @param: @param compay
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年8月21日
	 */
	public Map<String,Object> queryCompanyDtlById(Company company){
		company.setValidStsCd("1");
		Map<String,String> bean = companyMapper.queryCompanyDtlById(company);
		Map<String,Object> map1 = new HashMap<>();
		map1.put("beans", null);
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", ""); 
		return map1;
	}
	/**
	 * 
	 * @Title  公司介绍新增
	 * @Description:  saveCompanyInfo
	 * @param: @param compay
	 * @param: @return
	 * @return 
	 * @throws Exception 
	 * @throws
	 * @author zzx
	 * @Date 2018年8月15日
 */
	public Map<String,Object> saveCompanyInfo(Company compay) throws Exception{
		String companyId = getSequence("t_pt_company");		
		compay.setCompanyId(companyId);
		compay.setValidStsCd("1");
		int flag = companyMapper.saveCompanyInfo(compay);		
    	Map<String,Object> bean = new HashMap<>();
    	if(flag != 1){
    		bean.put("rtnCd", "9999");
    	}else {
    		bean.put("rtnCd", "00");
    	}
    	Map<String,Object> map1 = new HashMap<>();
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", "");		
    	return map1;
	}
	/**
		 * 
		 * @Title  公司介绍修改
		 * @Description:  updateCompanyInfo
		 * @param: @param compay
		 * @param: @return
		 * @return 
		 * @throws
		 * @author zzx
		 * @Date 2018年8月15日
	 */
	public Map<String,Object> updateCompanyInfo(Company compay) throws Exception{
		compay.setValidStsCd("1");
    	int flag = companyMapper.updateCompanyInfo(compay);
    	Map<String,String> delMap = new HashMap<>();
    	delMap.put("objId", compay.getCompanyId());
    	Map<String,Object> bean = new HashMap<>();
    	if(flag != 1){
    		bean.put("rtnCd", "9999");
    	}else {
    		bean.put("rtnCd", "00");
    	}
    	Map<String,Object> map1 = new HashMap<>();
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", "");		
    	return map1;
	}
	/**
	 * 
	 * @Title  公司介绍删除
	 * @Description:  delCompanyInfo
	 * @param: @param compay
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年8月21日
	 */
	public Map<String,Object> delCompanyInfo(Company compay) throws Exception{
		int flag = companyMapper.delCompanyInfo(compay);
		Map<String,Object> map1 = new HashMap<>();
		Map<String,Object> bean = new HashMap<>();
		if(flag != 1){
    		bean.put("rtnCd", "9999");
    	}else {
    		bean.put("rtnCd", "00");
    	}
		map1.put("bean",bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", "");		
    	return map1;
	}
}
